package uplift.project;

import java.util.ArrayList;

import uplift.project.model.VolunteerEvent;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

public class MyEventsOrganizingActivity extends ListActivity{
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.suggestions_list);
		
		ApplicationData appData = (ApplicationData)this.getApplicationContext();
		ArrayList<VolunteerEvent> vList = appData.eventsList.getUserCreatedEvents();
		
		BrowseAdapter adapter = new BrowseAdapter(this, android.R.layout.simple_list_item_1, vList);

		this.getListView().setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> a, View
					v, int position, long id) {
				Intent i = new Intent(v.getContext(), UserCreatedEventActivity.class);
				VolunteerEvent item = (VolunteerEvent)a.getItemAtPosition(position);
				i.putExtra("name", item.getName());
				i.putExtra("category", item.getCategory());
				i.putExtra("location", item.getLocation());
				i.putExtra("date", item.getDate());
				i.putExtra("starts", item.getStartTime());
				i.putExtra("ends", item.getEndTime());
				i.putExtra("description", item.getDescription());
				startActivity(i);
			}
		});

		setListAdapter(adapter);

	}


}